package org.ragdollcat.first.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.ragdollcat.first.api.ai.aliyun.model.CreateOutPaintingTaskResponse;
import org.ragdollcat.first.api.ai.aliyun.model.GetOutPaintingTaskResponse;
import org.ragdollcat.first.common.DeleteRequest;
import org.ragdollcat.first.model.dto.picture.*;
import org.ragdollcat.first.model.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import org.ragdollcat.first.model.entity.User;
import org.ragdollcat.first.model.vo.PictureVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author 86158
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-08-17 17:47:37
*/
public interface PictureService extends IService<Picture> {


    /**
     * 上传图片
     *
     * @param source        图片信息对象
     * @param pictureUploadRequest 上传图片请求对象
     * @param user                 当前登录人信息
     * @return 脱敏后的图片
     */
    PictureVO uploadPicture(Object source, PictureUploadRequest pictureUploadRequest, User user);

    /**
     * 图片更新参数校验
     *
     * @param pictureUpdateRequest
     */
    void vaildUpdPicParam(PictureUpdateRequest pictureUpdateRequest);

    /**
     * 分页获取图片列表，无需脱敏
     *
     * @param pictureQueryRequest
     * @return
     */
    Page<Picture> getPicPage(PictureQueryRequest pictureQueryRequest);

    /**
     * 组装图片查询条件
     * @param pictureQueryRequest
     * @return
     */
    Wrapper<Picture> composePicQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 普通用户获取脱敏后的图片分页数据
     * @param pictureQueryRequest
     * @return
     */
    Page<PictureVO> getPicPageVO(PictureQueryRequest pictureQueryRequest);

    /**
     * 将Picture对象脱敏
     * @param pic
     * @return
     */
    PictureVO castPicToPicVO(Picture pic);

    /**
     * 新增，修改图片时，填充审核参数
     * @param pic
     */
    void fillCheckParams(Picture pic,User user,boolean isUpdate);

    /**
     * 管理员审批图片
     *
     * @param pictureReviewRequest
     * @param httpServletRequest
     * @return
     */
    Boolean adminApprovePicture(PictureReviewRequest pictureReviewRequest, HttpServletRequest httpServletRequest);


    /**
     * 管理员批量抓取图片
     *
     * @param pictureUploadByBatchRequest
     * @param httpServletRequest
     * @return
     */
    Integer adminFetchPicture(PictureUploadByBatchRequest pictureUploadByBatchRequest, HttpServletRequest httpServletRequest);

    /**
     * 删除云端图片
     * @param pic
     */
    void deletePic(Picture pic);

    /**
     * 校验删除或修改图片有无对应的空间权限
     *
     * @param picture
     */
    void vaildPictureAuth(Picture picture,HttpServletRequest httpServletRequest);

    /**
     * 删除图片
     * @param deleteRequest
     * @param httpServletRequest
     * @return
     */
    Boolean deletePicById(DeleteRequest deleteRequest, HttpServletRequest httpServletRequest);

    /**
     * 根据颜色搜图
     *
     * @param searchPictureByColorRequest 图片空间 图片颜色值
     * @param loginUser                   用户登录信息
     * @return
     */
    List<PictureVO> searchPicByColor(SearchPictureByColorRequest searchPictureByColorRequest, User loginUser);

    /**
     * 用户批量编辑图片信息
     *
     * @param pictureEditByBatchRequest
     * @param httpServletRequest
     * @return
     */
    Boolean batchUserUpdatePic(PictureEditByBatchRequest pictureEditByBatchRequest, HttpServletRequest httpServletRequest);

    /**
     * 创建AI处理图片任务
     *
     * @param request
     * @param httpServletRequest
     * @return
     */
    CreateOutPaintingTaskResponse createPicHandletask(CreatePictureOutPaintingTaskRequest request, HttpServletRequest httpServletRequest);

    /**
     * 查询AI处理图片任务结果
     * @param taskId
     * @return
     */
    GetOutPaintingTaskResponse queryPicHandletask(String taskId);
}
